<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" th:fragment="posts (posts)">
<script type="text/javascript"  th:src="@{/webjars/jquery/3.5.1/jquery.js}"></script>
<div  id="posts" class="span-15" >

    <div class="post" th:each="post,iterStat:${posts}">
        <strong>
            <a th:text="${post.username}" th:href="@{/{username}(username=${session.username})}">
                {{ post.username }}
            </a>
        </strong>
        <div th:id="'content'+${iterStat.index}" >  <div th:id="contents+${iterStat.index}" th:text="${post.content}"></div></div>
        <div class="date" th:text="${#dates.format(post.date,'yyyy-MM-dd HH:mm:ss')}">{{ post.posttime }}</div>
    </div>

</div>
<script>
  $(document).ready(function(){
      for(let i=0;i<$('#posts div[class="post"]').length;i++){
          $("#content"+i).append($("#contents"+i).text())
          $("#contents"+i).remove()
      }
  });
</script>
</html>
